#include <stdio.h>
#include <string.h>
#include <math.h>
//#define pi (3.14159265358979)
main()
{
	double r,h,d1,a1,d2,a2,x1,x2,y1,y2;
	double c,d,zhou,cta,dis;
	double aa1,aa2;
	double pi;

	pi=asin(1)*2;
	while (scanf("%lf%lf%lf%lf%lf%lf", &r, &h, &d1, &a1, &d2, &a2)!=EOF)
	{
		c=sqrt(r*r+h*h);
		aa1=0;
		aa2=fabs(a1-a2);
		if (aa2>180) aa2=360-aa2;
		a1=aa1;
		a2=aa2;

		d=d1;
		zhou=a1/180*pi*r;
		cta=zhou/c;
		x1=d*cos(cta);
		y1=d*sin(cta);


		d=d2;
		zhou=a2/180*pi*r;
		cta=zhou/c;
		x2=d*cos(cta);
		y2=d*sin(cta);

		dis=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		printf("%.2lf\n", dis);

		
	}



	return 0;
}